<?php
include "general_include.php";
include "checklogin.php";
include "top.php";
include "left.php";

if($action=='delete')
{
  $timing_id = $_REQUEST['timing_id'];
  $DelSql = "DELETE FROM ".TABLEPREFIX."_timings where timing_id='$timing_id'";
  $UserManagerObjAjax->Execute($DelSql);
  if(!mysql_error())
  {
     echo "<script>window.location.href='timing.php'</script>";
	 exit; 
  }	 
}  


function findvalue($table,$fld_name,$fld_value,$find_value)
{
     if($fld_value=='')
			return false;
			
		$SelectTypeSql = "SELECT ".$find_value." FROM ".$table." WHERE $fld_name=".$fld_value;
		$SelectType = mysql_fetch_array(mysql_query($SelectTypeSql));
		return $SelectType[0];
}	


$Sqltime = "SELECT * FROM ".TABLEPREFIX."_timings WHERE user_id='".$_SESSION['user_id']."'";
$timeArr = $UserManagerObjAjax->GetRecords('All',$Sqltime);
$Numtime = count($timeArr);
for($t=0 ; $t<$Numtime; $t++)
{
   $timeArr[$t]['slot'] = findvalue(TABLEPREFIX."_time_slot","time_slot_id",$timeArr[$t]['time_slot_id'],"time_slot");

}

$smarty->assign('Numtime',$Numtime);
$smarty->assign('timeArr',$timeArr);
$smarty->display('timing.tpl');
include "footer.php";
?>